var happyReaderFlash = {
    flashData:[],
    inited:false,
    getData:function(){
        var filters = {
            ku6:{reg:/^(.*)\.ku6\.com$/, condition:'input[id="outSideSwfCode"]'},
            youku:{reg:/^(.*)\.youku\.com$/, condition:'input[id="link2"]'},
            pptv:{reg:/^(.*)\.pptv\.com$/, condition:'input[jsvalue="1"]'}
        };
        for(var key in filters){
            var filter = filters[key];
            if (filter.reg.test(location.host)){
                try{
                    var url = document.querySelectorAll(filter.condition)[0].value;
                    this.flashData.push({url:url, width:720, height:600});
                }catch(e){}
                break;
            }
        }
        if (this.flashData.length){
            return ;
        }

        var maxArea = 10,maxObj = null, curObj = null, swfs = document.querySelectorAll("[type='application/x-shockwave-flash']");
        for(var i=0,swf; swf=swfs[i++];){
            var flashvars = swf.getAttribute('flashvars'), 
                flashvarsParam = swf.querySelectorAll("param[name='flashvars']")[0],
                curArea = parseInt(swf.height) * parseInt(swf.width);
            
            if (!flashvars && flashvarsParam){
                flashvars = flashvarsParam.value;
            }
            curObj = {url:(swf.data||swf.src), width:swf.width, height:swf.height, flashvars:flashvars};
            if (curArea > maxArea){
                maxArea = curArea;
                maxObj = curObj;
            }
        }
        maxObj && this.flashData.push(maxObj);
    },
    init:function(){
        $('#happyReaderHeaderAD').html(_m("otherModeHeaderAD"));
		happyReader.setUserConfig("viewMode","swf");
        if (this.inited)return ;
        this.inited = true;
        
        var swf = this.flashData.pop(),
            html = "<p>"+_m("noSwf")+"</p>";
        swf && (html = '<article><embed id="flash_0" src="'+swf.url+'" width="'+swf.width+'" height="'+swf.height+'" flashvars="'+swf.flashvars+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></article>');
        $('#flashCanvas').css({left:0}).html(html);
    },
	checkModeValid:function(){
		return this.flashData.length > 0;
	}
};